home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Cream of the Crop 20
/
Cream of the Crop 20 (Terry Blount) (1996).iso
/
program
/
n_b_v203.zip
/
JUSTIFY.DMO
< prev
next >
Wrap
Text File
|
1996-07-04
|
3KB
|
78 lines
$if 0
┌──────────────────────────╖ PowerBASIC v3.20
┌──┤ DASoft ╟──────────────────────┬──────────────────╖
│ ├──────────────────────────╢ Copyright 1995 │ DATE: 1995-10-01 ╟─╖
│ │ FILE NAME JUSTIFY .DMO ║ by ╘════════════════─ ║ ║
│ │ ║ Don Schullian, Jr. ║ ║
│ ╘══════════════════════════╝ ║ ║
│ A license is hereby granted to the holder to use this source code in ║ ║
│ any program, commercial or otherwise, without receiving the express ║ ║
│ permission of the copyright holder and without paying any royalties, ║ ║
│ as long as this code is not distributed in any compilable format. ║ ║
│ IE: source code files, PowerBASIC Unit files, and printed listings ║ ║
╘═╤═════════════════════════════════════════════════════════════════════╝ ║
│ .................................... ║
╘═══════════════════════════════════════════════════════════════════════╝
$endif
'.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°
' ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° °
$INCLUDE "DAS-NB01.INC"
COLOR 7,0
CLS
? "┌─────────────────────────────────────────────────────────────────────────────
? "│ fJustify$ ( V$, MaxLen%, Which% )
? "├─────────────────────────────────────────────────────────────────────────────
? "│ This one you have to write yourself but it is quick and simple but provides
? "│ a very important service to any program that inputs data from the user.
? "│ All it does is call a series of justifying routines by number! Why? well, if
? "│ you assign your input fields with one of these numbers then it can call
? "│ whichever one you want (or your users choose) automatically. It really isn't
? "│ too user-friendly to make the user press <CAPS LOCK> just because you need
? "│ the data all in UCASE. PowerBASIC does it faster than the user anyhow!
? "│ eg: the user inputs: this is a test
? "│ the program wants: THIS IS A TEST
? "│ now you can either send the user an error message and make them
? "│ type it all over again or just UCASE it!
? "└─────────────────────────────────────────────────────────────────────────────
D$ = "This is a test."
PRINT "The test string is: "; CHR$(34); D$; CHR$(34)
PRINT
FOR Which% = 0 TO 4
PRINT CHR$(34); fJustify$( D$, 22, Which% ); CHR$(34)
NEXT
FUNCTION fJustify$ ( BYVAL V$, BYVAL L%, BYVAL Which% ) LOCAL PUBLIC
LOCAL I$
I$ = fRemoveDBLspc$( V$ ) ' remove double spaces
SELECT CASE Which%
CASE 00 : I$ = fLRtrim$ ( I$ )
CASE 01 : I$ = fJustLeft$ ( I$, L%, 32 )
CASE 02 : I$ = fJustCenter$( I$, L%, 32 )
CASE 03 : I$ = fJustRight$ ( I$, L%, 32 )
CASE 04 : I$ = fJustRight$ ( I$, L%, 48 ) ' PAD LEFT W/ 0s
END SELECT
FUNCTION = I$
END FUNCTION
$if 0
Try this idea for your input routines:
TYPE MyInputTYPE
Row AS BYTE ' the row to input at
Col AS BYTE ' left most column
Length AS BYTE ' maximum length of input
Style AS BYTE ' alpha, caps, numeric, etc.
Just AS BYTE ' final justification
END TYPE
DIM tI(20) AS MyInputTYPE
G$ = fInputAll$( tI(), D$() ) ' returns exiting key-press
$endif